home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / daemons / ipServer / RCS / sockInt.h,v < prev    next >
Encoding:
Text File  |  1989-08-16  |  9.6 KB  |  357 lines

  1. head     1.6;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.6
  10. date     89.08.15.19.55.38;  author rab;  state Exp;
  11. branches ;
  12. next     1.5;
  13.  
  14. 1.5
  15. date     89.03.23.09.52.52;  author brent;  state Exp;
  16. branches ;
  17. next     1.4;
  18.  
  19. 1.4
  20. date     89.02.21.10.06.43;  author brent;  state Exp;
  21. branches ;
  22. next     1.3;
  23.  
  24. 1.3
  25. date     88.08.16.11.22.08;  author mendel;  state Exp;
  26. branches ;
  27. next     1.2;
  28.  
  29. 1.2
  30. date     88.06.26.12.19.26;  author mendel;  state Exp;
  31. branches ;
  32. next     1.1;
  33.  
  34. 1.1
  35. date     88.04.27.09.01.36;  author brent;  state Exp;
  36. branches ;
  37. next     ;
  38.  
  39.  
  40. desc
  41. @Internal defs
  42. @
  43.  
  44.  
  45. 1.6
  46. log
  47. @Commented #endif labels.
  48. @
  49. text
  50. @/*
  51.  * sockInt.h --
  52.  *
  53.  *    Internal declarations of the socket-related routines.
  54.  *    The data structures defined in this filed are used to manage
  55.  *    sockets.
  56.  *
  57.  * Copyright 1987 Regents of the University of California
  58.  * All rights reserved.
  59.  * Permission to use, copy, modify, and distribute this
  60.  * software and its documentation for any purpose and without
  61.  * fee is hereby granted, provided that the above copyright
  62.  * notice appear in all copies.  The University of California
  63.  * makes no representations about the suitability of this
  64.  * software for any purpose.  It is provided "as is" without
  65.  * express or implied warranty.
  66.  *
  67.  *
  68.  * $Header: /sprite/src/daemons/ipServer/RCS/sockInt.h,v 1.5 89/03/23 09:52:52 brent Exp Locker: rab $ SPRITE (Berkeley)
  69.  */
  70.  
  71. #ifndef _IPS_SOCKINT
  72. #define _IPS_SOCKINT
  73.  
  74. #include "sprite.h"
  75. #include "dev/net.h"
  76. #include "netInet.h"
  77. #include "fs.h"
  78. #include "list.h"
  79. #include "proc.h"
  80.  
  81. #ifdef KERNEL
  82. #include "../fs/fsInt.h"
  83. #include "../fs/fsSocket.h"
  84. #endif
  85.  
  86. /*
  87.  * Sock_State defines the various states that a socket can be in at
  88.  * any one moment.
  89.  */
  90. typedef enum {
  91.     UNUSED,        /* Not in use. */
  92.     CREATED,        /* The socket has been created by opening the
  93.              * socket pseudo-device. */
  94.     HAVE_LOCAL_ADDR,    /* A bind operation has been performed. */
  95.     READY,        /* The socket can send and receive datagrams
  96.              * (datagram only). */
  97.     LISTENING,        /* A stream socket is waiting for connection
  98.              * requests from remote hosts. */
  99.     CONNECTING,        /* A stream socket trying to connect to a remote host.*/
  100.     CONNECTED,        /* Stream socket: the connection attempt succeeded.
  101.                  * Datagram socket: the local and remote addresses
  102.              * have been defined. */
  103.     DISCONNECTING,    /* In the process of disconnecting from a remote host */
  104.     DISCONNECTED,    /* The connection has been closed. */
  105. } Sock_State;
  106.  
  107.  
  108. /*
  109.  * There are two buffer queues for a socket. Data in the queue are
  110.  * held in a linked list.
  111.  */
  112. typedef struct {
  113.     List_Links        links;        /* List of Sock_BufDataInfo items. */
  114.     int            size;        /* # of bytes in the bufffer. */
  115.     int            maxSize;    /* Max. # of bytes allowed. */
  116. } Sock_BufInfo;
  117.  
  118.  
  119. /*
  120.  * Each data buffer in a socket buffer queue is described by this structure.
  121.  */
  122.  
  123. typedef struct {
  124.     List_Links    links;            /* All data are linked together */
  125.     Net_InetSocketAddr    address;    /* For reads, who sent the packet. */
  126.     int        len;            /* Number of bytes stored. */
  127.     Address    bufPtr;            /* Ptr to the data buffer. */
  128.     Address    base;            /* Base address of the Mem_Alloc'd
  129.                      * memory used for bufPtr. This is
  130.                      * the address given to Mem_Free when
  131.                      * info is no longer needed. */
  132. } Sock_BufDataInfo;
  133.  
  134. /*
  135.  * Information about the peudo-device request buffer associated with
  136.  * each socket.  This is set up and used when the pseudo-device connection
  137.  * is just being created.  It is passed to the Sock_Open routine, and the
  138.  * location of the request buffer is used for cleanup and for error checking.
  139.  */
  140.  
  141. typedef struct SockPdevState {
  142.     int protoIndex;        /* Type for Sock_SharedInfo */
  143.     int reqBufSize;        /* Size of the request buffer */
  144.     char *requestBuf;        /* The request buffer itself */
  145. } SockPdevState;
  146.  
  147. /*
  148.  * Information about a socket that is shared among processes using the socket.
  149.  *  1) current state of use, protocol type.
  150.  *  2) pointer to protocol-dependent information.
  151.  *  3) queues that hold data to be sent to another socket
  152.  *     and data that has been received from another socket.
  153.  *  4) info about the local and remote addresses assigned to this socket.
  154.  *
  155.  */
  156. typedef struct Sock_SharedInfo {
  157.     List_Links        protoLinks;    /* Links to others of same protocol. */
  158.     int            protoIndex;    /* One of RAW_PROTO_INDEX,
  159.                      * UDP_PROTO_INDEX, TCP_PROTO_INDEX. */
  160.     int            protocol;    /* For raw sockets: the IP protocol #
  161.                      * that must be present in incoming
  162.                      * packet in order to be received;
  163.                      * protocol # used in IP header on
  164.                      * output. */
  165.     ClientData        protoData;    /* Protocol-specific information. */
  166.     int            reqBufSize;    /* Size of the pdev request buffer */
  167.     char            *requestBuf;    /* The pdev request buffer.  Packet
  168.                      * data is put here by the kernel, and
  169.                      * we format packets in place (without
  170.                      * copies) before outputing to the net*/
  171.     Sock_State        state;        /* Defined above. */
  172.     int            options;    /* Manipulated via IOC_NET_GET_OPTION/
  173.                      * SET_OPTION in <dev/net.h>. */
  174.     Ioc_Owner        owner;        /* Current owner (process or family). */
  175.     int            flags;        /* Defined below. */
  176.     int            clientCount;    /* # of users using this socket. */
  177.     ReturnStatus    error;        /* Asynchronous error status from
  178.                      * ICMP or from the protocol-dependent
  179.                      * layer. */
  180.     Sock_BufInfo    recvBuf;    /* Data from the network. */
  181.     Sock_BufInfo    sendBuf;    /* Data to be sent out. */
  182.  
  183.     Net_InetSocketAddr    local;        /* Address for this host. */
  184.     Net_InetSocketAddr    remote;        /* Address for remote host. */
  185.  
  186.     Net_InetSocketAddr    sentTo;        /* Destination of the most-recently
  187.                      * sent packet (only if not connected.)
  188.                      */
  189.     int            linger;        /* # of seconds to wait upon closing. */
  190.     struct Sock_SharedInfo *parentPtr;    /* Used to wakeup a socket waiting to
  191.                      * accept a new connection. */
  192.     List_Links        clientList;    /* List of clients using this socket.
  193.                      * Used to notify when the select state
  194.                      * changes. */
  195.     Boolean        justEstablished; /* Used by a connection-based
  196.                      * protocol's select routine to notify
  197.                      * a waiter that the connection has
  198.                      * just become established. */
  199. } Sock_SharedInfo;
  200.  
  201. /*
  202.  * Sock_SharedInfo flags:
  203.  *    SOCK_STOP_RECV        - don't accept any more data.
  204.  *    SOCK_STOP_SEND        - can't send data any more.
  205.  *    SOCK_URGENT_DATA_NEXT    - urgent data is at the next logical byte
  206.  *                  in the receive buffer.
  207.  *    SOCK_RAW_HAVE_LOCAL_ADDR - for raw sockets, the local address field
  208.  *                   contains a usable address.
  209.  *    SOCK_HAVE_BOUND_ADDR     - An address has been bound to the socket
  210.  *                   with a bind operation. This flag is used
  211.  *                   to prevent mutiple bind operations on the
  212.  *                   same socket.
  213.  */
  214.  
  215. #define SOCK_STOP_RECV            0x01
  216. #define SOCK_STOP_SEND            0x02
  217. #define SOCK_URGENT_DATA_NEXT        0x04
  218. #define SOCK_RAW_HAVE_LOCAL_ADDR    0x08
  219. #define    SOCK_HAVE_BOUND_ADDR        0x10
  220.  
  221.  
  222. /*
  223.  * SOCK_MAX_LINGER_TIME    - linger at most 2 minutes.
  224.  */
  225. #define    SOCK_MAX_LINGER_TIME    120
  226.  
  227. /*
  228.  * Information about a socket that must be kept for each process using the
  229.  * socket.
  230.  */
  231. typedef struct Sock_PrivInfo {
  232.     List_Links        links;        /* Used to attach this element to the
  233.                      * socket's clientList. */
  234.     Sock_SharedInfo    *sharePtr;    /* Common socket info. */
  235. #ifndef KERNEL
  236.     int            streamID;    /* Pdev stream ID. */
  237. #else
  238.     struct FsSocketIOHandle    *sockHandlePtr;    /* Back pointer to FS handle */
  239. #endif
  240.     int            fsFlags;    /* Flags from Fs_Open. */
  241.     Proc_PID        pid;        /* Process using this socket. */
  242.     int            hostID;        /* Host where process is based. */
  243.     int            userID;        /* User-ID of the process. */
  244.     int            clientID;    /* Client ID for the pdev.  */
  245.     int            recvFlags;    /* Flags from IOC_NET_RECV_FLAGS ioctl.
  246.                      * Needed to emulate recv, recvfrom,
  247.                      * recvmsg. Defined in <dev/net.h>. */
  248.     Net_InetSocketAddr    recvFrom;    /* Source of the packet that was just
  249.                      * read. Needed for recvfrom, recvmsg
  250.                      * emulation. */
  251.     Net_SendInfo    sendInfo;    /* Info from IOC_NET_SEND_INFO ioctl.
  252.                      * Needed to emulate send,sendto,
  253.                      * sendmsg. */
  254.     Boolean        sendInfoValid;    /* If TRUE, the sendInfo is useful. */
  255. } Sock_PrivInfo;
  256.  
  257.  
  258. #endif /* _IPS_SOCKINT */
  259. @
  260.  
  261.  
  262. 1.5
  263. log
  264. @Added #ifdef KERNEL
  265. @
  266. text
  267. @d19 1
  268. a19 1
  269.  * $Header: /sprite/src/daemons/ipServer/RCS/sockInt.h,v 1.4 89/02/21 10:06:43 brent Exp $ SPRITE (Berkeley)
  270. d43 1
  271. a43 1
  272.     CREATED,        /* The socket has been created by opening the 
  273. d61 1
  274. a61 1
  275.  * held in a linked list. 
  276. d102 1
  277. a102 1
  278.  *  3) queues that hold data to be sent to another socket 
  279. d109 1
  280. a109 1
  281.     int            protoIndex;    /* One of RAW_PROTO_INDEX, 
  282. d111 2
  283. a112 2
  284.     int            protocol;    /* For raw sockets: the IP protocol # 
  285.                      * that must be present in incoming 
  286. d143 1
  287. a143 1
  288.     List_Links        clientList;    /* List of clients using this socket. 
  289. d146 3
  290. a148 3
  291.     Boolean        justEstablished; /* Used by a connection-based 
  292.                      * protocol's select routine to notify 
  293.                      * a waiter that the connection has 
  294. d161 1
  295. a161 1
  296.  *                   with a bind operation. This flag is used 
  297. d200 1
  298. a200 1
  299.                      * read. Needed for recvfrom, recvmsg 
  300. d209 1
  301. a209 1
  302. #endif _IPS_SOCKINT
  303. @
  304.  
  305.  
  306. 1.4
  307. log
  308. @Changed the Open interface a bit to pass information about
  309. the pseudo-device request buffer
  310. @
  311. text
  312. @d19 1
  313. a19 1
  314.  * $Header: /sprite/src/daemons/ipServer/RCS/sockInt.h,v 1.3 88/08/16 11:22:08 mendel Exp Locker: brent $ SPRITE (Berkeley)
  315. d32 4
  316. d186 1
  317. d188 3
  318. @
  319.  
  320.  
  321. 1.3
  322. log
  323. @Converted to new lib.a.
  324. @
  325. text
  326. @d19 1
  327. a19 1
  328.  * $Header: sockInt.h,v 1.2 88/06/26 12:19:26 mendel Exp $ SPRITE (Berkeley)
  329. d81 6
  330. d88 6
  331. d113 5
  332. @
  333.  
  334.  
  335. 1.2
  336. log
  337. @Added a flag used to dectect multiple bind operations on the same socket.
  338. @
  339. text
  340. @d19 1
  341. a19 1
  342.  * $Header: sockInt.h,v 1.1 88/04/27 09:01:36 brent Exp $ SPRITE (Berkeley)
  343. @
  344.  
  345.  
  346. 1.1
  347. log
  348. @Initial revision
  349. @
  350. text
  351. @d19 1
  352. a19 1
  353.  * $Header: sockInt.h,v 6.0 87/09/08 15:57:47 andrew Stable $ SPRITE (Berkeley)
  354. d139 4
  355. d149 1
  356. @
  357.